Dekoratives Banner

Dialogs and Console


    This script shows how to use the various dialogs (alert(), prompt(), confirm()) and how to write to the info palette (write(), writeLn() and clearOutput()). Although this script serves no practical use, these dialogs and info palette prompts are highly useful and should be familiar to all script creators.

    // Use confirm() to let the user tell us whether he can see the "info" window.
    // Depending how the user clicks, true or false is returned.
    if (confirm("Can you see the \"info\" palette?")){
        // Start by clearing the information area.
        clearOutput();
        // write and writeLn will write to the info tab with or without a
        //'newline'
        // at the end.
        write("Roses are red,");
        writeLn("violets are blue");
        write("Sugar is sweet,");
        writeLn("and so is Equal.");
        var reply = prompt( "Did you like my poem?");
        if (reply == "yes" || reply == "YES"){
            alert("See the info window for a special secret fortune.");
            // This gets rid of the old writing on the info tab.
            clearOutput();
            writeLn("You have a future as a literary critic.");
        }
        else {
            alert("Hmm, I'll try once more...");
            writeLn(".......");
            writeLn("Roses are red, violets are blue,");
            writeLn("I've got some gum, on the sole of my shoe.");
        }
        alert("Okay, all done with this test.");
    }
    else {
        // alert() just displays a message in a dialog box.
        alert("Please make it so you can see the info palette and run this script
        again");
    }